import 'package:flutter/material.dart';
import 'package:jm_flutter/jm_flutter.dart';

import '../../controller/app_controller.dart';
import 'test_page.dart';

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final tag = "HomePage";

  AppController appController = findApp;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: JmColors.bg,
      body: SafeArea(
        child: SingleChildScrollView(
          padding: const EdgeInsets.all(24),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              MyButton(
                text: "aboutPage",
                onPressed: () {
                  gotoNamed(JmPages.aboutPage);
                },
              ),
              MyButton(
                text: "TestPage",
                onPressed: () {
                  goto(() => const TestPage());
                },
              ),
              MyButton(
                text: "MyDebugPage",
                onPressed: () {
                  gotoDeveloperPage(
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                      children: [
                        MyButton(
                          text: "村上春树",
                          onPressed: () {
                            logd(tag, '8989');
                          },
                        ),
                        MyButton(
                          text: "村上春树",
                          onPressed: () {},
                        ),
                      ],
                    ),
                  );
                },
              ),
              FilledButton(
                onPressed: null,
                style: ButtonStyle(
                  backgroundColor: MaterialStateProperty.all(JmColors.main),
                  //minimumSize: MaterialStateProperty.all(Size(100, 28)),
                  // shape: MaterialStateProperty.all(
                  //   RoundedRectangleBorder(
                  //     borderRadius: BorderRadius.circular(12),
                  //   ),
                  // ),
                ),
                child: MyText("测试按钮", color: Colors.white),
              ),
              FilledButton.icon(
                onPressed: () {},
                icon: const Icon(
                  CupIcons.arrow_right_square_fill,
                  weight: 1000,
                ),
                label: MyText("测试按钮", color: Colors.white),
                style: ButtonStyle(
                  backgroundColor: MaterialStateProperty.all(JmColors.main),
                  // shape: MaterialStateProperty.all(
                  //   RoundedRectangleBorder(
                  //     borderRadius: BorderRadius.circular(12),
                  //   ),
                  // ),
                ),
              ),
              MyButton(
                onPressed: () {},
                text: "测试按钮",
                enable: false,
                icon: const Icon(
                  CupIcons.add,
                  weight: 1,
                ),
              ),
              MyButton.outlined(
                onPressed: () {},
                text: "测试按钮",
                icon: const Icon(
                  CupIcons.arrow_right_square_fill,
                ),
              ),
              MyButton.gray(
                onPressed: () {},
                text: "测试按钮(gray)",
                icon: const Icon(
                  CupIcons.arrow_right_square_fill,
                ),
              ),
              MyButton(
                onPressed: () {},
                text: "测试按钮(小)",
                size: MyButtonSize.small,
              ),
              MyButton.large(
                onPressed: () {
                  goto(() => const AppFilePage());
                },
                text: "测试按钮(大)",
                icon: const Icon(
                  Icons.access_time_filled_sharp,
                  weight: 1,
                ),
              ),
              gapv8,
              Row(
                children: [
                  Expanded(
                    child: MyButton.large(
                      type: MyButtonType.gray,
                      onPressed: () {},
                      text: "测试按钮(大)",
                      icon: const Icon(
                        Icons.access_time_filled_sharp,
                        weight: 1,
                      ),
                    ),
                  ),
                  gaph8,
                  Expanded(
                    child: MyButton.large(
                      type: MyButtonType.filled,
                      onPressed: () {},
                      text: "测试按钮(大)",
                      icon: const Icon(
                        Icons.access_time_filled_sharp,
                        weight: 1,
                      ),
                    ),
                  ),
                ],
              ),
              gapv8,
              Row(
                children: [
                  MyButton.large(
                    expanded: false,
                    type: MyButtonType.gray,
                    onPressed: () {},
                    text: "测试按钮(大)",
                    icon: const Icon(
                      Icons.access_time_filled_sharp,
                      weight: 1,
                    ),
                  ),
                  gaph8,
                  MyButton.large(
                    expanded: false,
                    type: MyButtonType.filled,
                    onPressed: () {},
                    text: "测试按钮(大)",
                    icon: const Icon(
                      Icons.access_time_filled_sharp,
                      weight: 1,
                    ),
                  ),
                ],
              ),
              gapv8,
              MyBigButton(
                onPressed: () {},
                text: "MyBigButton(大)",
                icon: const Icon(
                  Icons.access_time_filled_sharp,
                  weight: 1,
                ),
              ),
              gapv8,
              MyButton(
                type: MyButtonType.outlined,
                radius: 8,
                onPressed: () {},
                text: "测试",
              ),
              ElevatedButton(
                onPressed: () {},
                child: MyText("ElevatedButton"),
                style: ButtonStyle(
                  backgroundColor: MaterialStateProperty.all(Colors.red),
                  foregroundColor: MaterialStateProperty.all(Colors.white),
                  elevation: MaterialStateProperty.all(0),
                  shape: MaterialStateProperty.all(
                    RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(12),
                    ),
                  ),
                ),
              ),
              TextButton(onPressed: null, child: Text("TextButton")),
              OutlinedButton(onPressed: () {}, child: MyText("OutlinedButton")),
              SizedBox(
                  width: double.infinity,
                  child: FilledButton(
                      onPressed: () {},
                      child: MyText("FilledButton", color: Colors.white))),
              FilledButton(
                onPressed: () {},
                child: Text("FilledButton"),
                style: ButtonStyle(
                  minimumSize: MaterialStateProperty.all(Size(100, 28)),
                  padding: MaterialStateProperty.all(EdgeInsets.zero),
                  shape: MaterialStateProperty.all(
                    RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(12),
                    ),
                  ),
                  overlayColor: MaterialStateProperty.all(Colors.red),
                ),
              ),
              FilledButton.tonal(onPressed: () {}, child: Text("FilledButton")),
            ],
          ),
        ),
      ),
    );
  }
}
